import os
import sys
import envsettings

# Django settings for datahandler project.
# ENVIOREMENT deb ser 'dev' localmente y 'testing' en el servidor de pruebas
ENVIRONMENT = envsettings.environment
PROJECT_DIR = os.path.dirname(__file__)

ADMINS = (
    ('Guillermo Alvarez', 'guialante@gmail.com'),
)

MANAGERS = ADMINS


if ENVIRONMENT == 'development':
    DEBUG = True
    TEMPLATE_DEBUG = DEBUG
    BASE_DOMAIN = "tunegocioempresarios.local"
    BASE_URL = "http://tunegocioempresarios.local"
    MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
    MEDIA_URL = 'http://media.tunegocioempresarios.local/'
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
            'NAME': 'django.db',                      # Or path to database file if using sqlite3.
            'USER': '',                      # Not used with sqlite3.
            'PASSWORD': '',                  # Not used with sqlite3.
            'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
            'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
        }
    }        
    TIME_ZONE = 'America/Bogota'
    LANGUAGE_CODE = 'es-co'
    CACHE_BACKEND = 'locmem:///'
    ADMIN_MEDIA_PREFIX = '/media/'    
    EMAIL_HOST = envsettings.email_host
    EMAIL_HOST_USER = envsettings.email_host_user
    EMAIL_HOST_PASSWORD = envsettings.email_host_password
    DEFAULT_FROM_EMAIL = envsettings.default_from_email
    EMAIL_SUBJECT_PREFIX = envsettings.email_subject_prefix
    EMAIL_USE_TLS = True
    EMAIL_PORT = envsettings.email_port    

elif ENVIRONMENT == 'server':    
    sys.path.append(PROJECT_DIR)
    DEBUG = False
    TEMPLATE_DEBUG = DEBUG
    BASE_DOMAIN = "tunegocioempresarios.com"
    BASE_URL = "http://tunegocioempresarios.com"
    MEDIA_ROOT = '/home/guialante/webapps/datahandler_static_media/'
    MEDIA_URL = 'http://media.tunegocioempresarios.com/'
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
            'NAME': envsettings.db_name,                      # Or path to database file if using sqlite3.
            'USER': envsettings.db_user,                      # Not used with sqlite3.
            'PASSWORD': envsettings.db_pass,                  # Not used with sqlite3.
            'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
            'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
        }
    }
    TIME_ZONE = 'America/Bogota'
    LANGUAGE_CODE = 'es-co'
    CACHE_BACKEND = 'locmem:///'
    ADMIN_MEDIA_PREFIX = 'http://media.tunegocioempresarios.com/admin/'    
    EMAIL_HOST = envsettings.email_host
    EMAIL_HOST_USER = envsettings.email_host_user
    EMAIL_HOST_PASSWORD = envsettings.email_host_password
    DEFAULT_FROM_EMAIL = envsettings.default_from_email
    EMAIL_SUBJECT_PREFIX = envsettings.emai_subject_prefix
    EMAIL_USE_TLS = True
    EMAIL_PORT = envsettings.email_port


SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True


# Make this unique, and don't share it with anybody.
SECRET_KEY = '-7$6m$ou4-jz-lw$4r(ujd!l0e=0wd5r3!4t)l(3hxkr%_*zqn'


TEMPLATE_DIRS = (
   os.path.join(PROJECT_DIR, "templates"),
)



# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    

)

ROOT_URLCONF = 'datahandler.urls'


#TEMPLATE_CONTEXT_PROCESSORS = (
#    'django.core.context_processors.request',
#)


INSTALLED_APPS = (
    
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.admin',
    
    'apps.ajax',
    'apps.amway',
    'apps.estadisticas',
    'apps.l10n',
    'apps.perfil',
    'apps.registration',    
    'apps.utils',
    'apps.django_extensions',
)

FILE_UPLOAD_TEMP_DIR = os.path.join(PROJECT_DIR, 'upload', 'users')
SESSION_COOKIE_NAME ="tunegocioempresarios"
INTERNAL_IPS = ('127.0.0.1')

ACCOUNT_ACTIVATION_DAYS = 7
AUTH_PROFILE_MODULE = 'perfil.Empresario'

LOGIN_REDIRECT_URL = '/'
INDEX_DIR = os.path.join(PROJECT_DIR, 'indexdir')


